package me.chanjar.weixin.mp.util.json;

import java.lang.reflect.Type;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

import me.chanjar.weixin.common.util.json.GsonHelper;
import me.chanjar.weixin.mp.bean.result.WxMpCardCreateResult;

/**
 *
 * @author francis
 * @version 18/04/11
 */
public class WxMpCardCreateResultGsonAdapter implements JsonDeserializer<WxMpCardCreateResult> {
  @Override
  public WxMpCardCreateResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
	WxMpCardCreateResult createResult = new WxMpCardCreateResult();
    JsonObject jsonObject = jsonElement.getAsJsonObject();

    createResult.setCardId(GsonHelper.getString(jsonObject, "card_id"));
    createResult.setErrorCode(GsonHelper.getString(jsonObject, "errcode"));
    createResult.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg"));

    return createResult;
  }
}
